package com.aerozhonghuan.logisticsmall.modules.mine.logic;

import android.content.Context;

import com.aerozhonghuan.logisticsmall.framework.base.URLs;
import com.aerozhonghuan.logisticsmall.modules.mine.beans.MessageListBean;
import com.aerozhonghuan.logisticsmall.widget.ProgressDialogIndicator;
import com.aerozhonghuan.oknet2.CommonCallback;
import com.aerozhonghuan.oknet2.RequestBuilder;
import com.google.gson.reflect.TypeToken;

/**
 * 描述
 *
 * @author zhangyonghui
 * 创建日期 2019-05-23
 */
public class MineWebRequest {

    /**
     * 我的二网公司列表
     *
     * @param context
     * @param dialog
     * @param callback
     */
    public static void requestCompanys(Context context, ProgressDialogIndicator dialog, CommonCallback<String> callback) {
        RequestBuilder.with(context)
                .URL(URLs.SERVER_COMPANY_LIST)
                .progress(dialog)
                .onSuccess(callback).excute();
    }

    /**
     * 切换二网公司
     *
     * @param context
     * @param dialog
     * @param callback
     */
    public static void changeCompany(Context context, String companyId, ProgressDialogIndicator dialog, CommonCallback<String> callback) {
        RequestBuilder.with(context)
                .URL(URLs.SERVER_COMPANY_SWITCH)
                .para("companyId", companyId)
                .progress(dialog)
                .onSuccess(callback).excute();
    }

    /**
     * 反馈
     *
     * @param context
     * @param dialog
     * @param callback
     */
    public static void confirmFeedback(Context context, String title, String text, ProgressDialogIndicator dialog, CommonCallback<String> callback) {
        RequestBuilder.with(context)
                .URL(URLs.SERVER_FEEDBACK)
                .para("title", title)
                .para("text", text)
                .progress(dialog)
                .onSuccess(callback).excute();
    }

    /**
     * 是否存在未读消息
     *
     * @param context
     * @param callback
     */
    public static void isHaveUnreadMsg(Context context, CommonCallback<String> callback) {
        RequestBuilder.with(context)
                .URL(URLs.SERVER_REMIND)
                .onSuccess(callback).excute();
    }

    /**
     * 我的消息列表
     *
     * @param context
     * @param callback
     */
    public static void queryMessageList(Context context, int pageNumber, CommonCallback<MessageListBean> callback) {
        callback.setResponseType(new TypeToken<MessageListBean>() {
        });
        RequestBuilder.with(context)
                .URL(URLs.SERVER_MESSAGE_LIST)
                .para("pageSize", "20")
                .para("pageNumber", pageNumber)
                .onSuccess(callback).excute();
    }
}
